/* 
 * ProjectFile: message-broker\src\utils\resultParse.js
 * Created: lijianwei 2022-06-02 23:17:37
 * -----
 * LastModified: lijianwei 2023-01-10 10:48:52
 * -----
 * Copyright (c) 2016-2023 Rongwen Tech Ltd.
 * -----
 */

export function resDecode(string) {
    let res = {
        status: -99,
        data: {},
        msg: 'illegal format',
    }
    try {
        const new_res = JSON.parse(string);
    } catch (error) {
        console.log('{jsonDecode - error}', error.message())
        return res
    }
    return new_res

}

/**
 * 
 * @param {object} data 
 * @returns 
 */
export function resEncode(data) {
    

    let res = {
        status: 0,
        data: data,
        msg: 'illegal format',
    }
    return JSON.stringify(res)
}

